import http from '@/utils/request.js'

/**
 * 获取用户频道下的文章列表
 * @param {*} channelId
 * @param {*} timestamp
 */
export const reqGetArticles = (channelId, timestamp) => {
  return http({
    method: 'get',
    url: '/app/v1_1/articles',
    params: {
      with_top: 1,
      channel_id: channelId,
      timestamp
    }
  })
}

/**
 * 不喜欢文章
 * @param {*} articleId  文章ID
 */
export const reqDislikeArticles = (articleId) => {
  return http({
    method: 'post',
    url: '/app/v1_0/article/dislikes',
    data: {
      target: articleId
    }
  })
}

/**
 * 举报文章
 * @param {*} articleId  文章id
 * @param {*} type 举报类型
 */
export const reqReportArticles = (articleId, type) => {
  return http({
    method: 'post',
    url: '/app/v1_0/article/reports',
    data: {
      target: articleId,
      type
    }
  })
}

/**
 *获取文章详情
 */
export const reqArticleDetail = (articleId) => {
  return http({
    method: 'get',
    url: `/app/v1_0/articles/${articleId}`
  })
}

/**
 * 关注用户
 * @param {*} userId 关注的用户id
 */
export const reqFollower = (userId) => {
  return http({
    method: 'post',
    url: '/app/v1_0/user/followings',
    data: {
      target: userId
    }
  })
}

/**
 * 取消关注
 * @param {*} userId 用户id
 */
export const reqUnFollower = (userId) => {
  return http({
    method: 'delete',
    url: `/app/v1_0/user/followings/${userId}`
  })
}

/**
 * 对文章点赞
 * @param {*} articleId
 */
export const reqLikings = (articleId) => {
  return http({
    method: 'post',
    url: '/app/v1_0/article/likings',
    data: {
      target: articleId
    }
  })
}

/**
 * 取消对文章点赞
 * @param {*} articleId
 */
export const reqDelLikings = (articleId) => {
  return http({
    method: 'delete',
    url: `/app/v1_0/article/likings/${articleId}`
  })
}

/**
 * 对文章不喜欢
 * @param {*} articleId
 */
export const reqAddDislikes = (articleId) => {
  return http({
    method: 'post',
    url: '/app/v1_0/article/dislikes',
    data: {
      target: articleId
    }
  })
}

/**
 * 取消对文章的不喜欢
 * @param {*} articleId
 */
export const reqDelDislikes = (articleId) => {
  return http({
    method: 'delete',
    url: `/app/v1_0/article/dislikes/${articleId}`
  })
}
